package com.itheima.d3_stream;

import java.util.*;
import java.util.stream.Stream;

/*
        目标：掌握Stream流的创建。

        1 单列集合获取Stream流
        2 双列集合获取Stream流
        3 数组获取Stream流
        4 同一种类型多个数据获取Stream流
 */
public class StreamTest2 {
    public static void main(String[] args) {
        // 1、如何获取List集合的Stream流？
//        List<String> names = new ArrayList<>();
//        Collections.addAll(names, "张三丰","张无忌","周芷若","赵敏","张强");
//
//        Stream<String> streamOne = names.stream();
//
//        streamOne.forEach(name -> System.out.println(name));

        // 1 单列集合获取Stream流
        List<String> names = new ArrayList<>();
        Stream<String> streamList = names.stream();

        // 2 双列集合获取Stream流
        HashMap<Integer, String> doubleMap = new HashMap<>();
        // 2.1 键个值分别获取
        Stream<Integer> keyStream = doubleMap.keySet().stream();
        Stream<String> valueStream = doubleMap.values().stream();
        // 2.2 或entrySet获取流
        Stream<Map.Entry<Integer, String>> entryStream = doubleMap.entrySet().stream();

        // 3 数组获取Stream流
        Integer[] arr = {100, 500, 200, 300};
        Stream<Integer> arrStream = Stream.of(arr);
    }
}
